

#ifndef __VECTOR_HPP
#define __VECTOR_HPP


#define Assert assert
#include <assert.h>
//#include "Array.h"

template< class T >
class Vector
{
public:
	Vector( void );
	Vector( const Vector<T>& V );
	Vector( size_t N );
	Vector( size_t N, const T * pV );
	~Vector( void );

	const T& operator () (size_t i) const;
	T& operator () (size_t i);
	const T& operator [] (size_t i) const;
	T& operator [] (size_t i);

	void SetZero();

	size_t Dimensions() const;
	void Resize( size_t N );

	Vector operator * (const T& A) const;
	Vector operator / (const T& A) const;
	Vector operator - (const T& A) const;
	Vector operator + (const T& A) const;
	Vector operator - (const Vector& V) const;
	Vector operator + (const Vector& V) const;

	Vector& operator *= ( const T& A );
	Vector& operator /= ( const T& A );
	Vector& operator += ( const T& A );
	Vector& operator -= ( const T& A );
	Vector& operator += ( const Vector& V );
	Vector& operator -= ( const Vector& V );

	Vector& Add( const Vector* V , int count );
	Vector& AddScaled( const Vector& V , const T& scale );
	Vector& SubtractScaled( const Vector& V , const T& scale );
	static void Add( const Vector& V1 , const T& scale1 , const Vector& V2 , const T& scale2 , Vector& Out );
	static void Add( const Vector& V1 , const T& scale1 , const Vector& V2 , Vector& Out );

	Vector operator - () const;

	Vector& operator = (const Vector& V);

	T Dot( const Vector& V ) const;

	T Length() const;

	T Average() const;

	T Norm( size_t Ln ) const;
	void Normalize();

	bool write( FILE* fp ) const;
	bool write( const char* fileName ) const;
	bool read( FILE* fp );
	bool read( const char* fileName );
	T* m_pV;
protected:
	size_t m_N;

};

template< class C >       C* GetPointer(       Vector< C >& v ){ return &v[0]; }
template< class C > const C* GetPointer( const Vector< C >& v ){ return &v[0]; }


#include "Vector.inl"

#endif
